<template>
    <div>
        signalr connect
        <div>
            <div>signalr</div>
            <input placeholder="请输入..." />
            <Button type="info" id="publishReport" @click="add">信息按钮</Button>
            <ul id="msglist"></ul>
        </div>
    </div>
    </template>
    <script>
// let hubUrl = "http://192.168.1.111/chathub";
// let httpConnection = new signalR.HttpConnection(hubUrl);
// let hubConnection = new signalR.HubConnection(httpConnection);
import * as signalr from "../../signalr/signalr";
export default {
  mounted() {
      //建立连接
    signalr.hubConnection.start();
    //服务器回调方法
    signalr.hubConnection.on("Show", data => {
      $("#msglist").append($("<li>").text(data));
    });
  },
  methods: {
    add() {
      let msg = {
        userName: 3,
        message: 4564654
      };
      //服务器端回掉方法
      signalr.hubConnection.invoke("SendMsg", msg);
    }
  }
};
</script>

<style>

</style>
